<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <ul>
            <li v-for="(item, index) in users">
                {{item}}
            </li>
        </ul>
    </div>
</body>

<script src="./node_modules/vue/dist/vue.js"></script>
<script src="./node_modules/axios/dist/axios.js"></script>

<script>
    //1. 还没有调用getAllUsers方法
    let vm = new Vue({
        el: "#app",
        data() {
            return {
                users:[]
            }
        },
        mounted() {
            this.getAllUsers();
        },
        methods: {
            getAllUsers() { 
                axios.get('http://localhost:8811/user/getAllUsers'
                    //, {
                    //     params: {
                    //         ID: 12345
                    //     }
                    // }
                    )
                    // 当使用箭头函数  this 指向的是外层
                    .then(response =>{
                        this.users=response.data.data;
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            }
        },
    }) 
</script>

</html>